const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      openid:app.loginData.openid
    });
  },
  getPhone(e){
    this.setData({
      phone:e.detail.value
    });
  },
  doLogin(){
    console.log(this.data.openid);
    wx.getUserProfile({
      desc: '用户授权登录',
      success:res=>{
        // console.log(res);
        wx.request({
          url: 'http://127.0.0.1:3000/loginAndRegist',
          method:"post",
          data:{
            openid:this.data.openid,
            phone:this.data.phone,
            nickname:res.userInfo.nickName,
            img:res.userInfo.avatarUrl
          },
          success:result=>{
            app.loginData=result.data;
            wx.navigateBack();
          }
        })
      }
    })
  }
 
})